/**
 * The preload script runs before. It has access to web APIs
 * as well as Electron's renderer process modules and some
 * polyfilled Node.js functions.
 *
 * https://www.electronjs.org/docs/latest/tutorial/sandbox
 */

const { contextBridge, ipcRenderer } = require("electron");

async function im_open() {
  try {
    const data = await ipcRenderer.invoke("im_open");

    return data;
  } catch (e) {
    throw e;
  }
}

async function json_open() {
  const data = await ipcRenderer.invoke("json_open");

  return data
}

contextBridge.exposeInMainWorld("IM", {
  open: im_open,
  json_open: json_open
});